/*
 * Copyright (c) 2015. For Intelligent Group.
 */

package com.intelligent.ispc.core.entity;

import com.google.common.collect.Lists;
import com.intelligent.ispc.common.persistence.BaseEntity;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;

import javax.persistence.*;
import java.util.Date;
import java.util.List;

/**
 * Created by Peter.Li on 2015/10/19.
 */
@Entity
@Table(name = "t_project")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class Project extends BaseEntity {
    private String code;
    private String name;
    private String description;
    private Integer yieldCycleValue;
    private Boolean yieldCycleUnit;

    @Temporal(TemporalType.TIMESTAMP)
    private Date updateTime;

    @ManyToMany(targetEntity = Group.class, fetch = FetchType.EAGER)
    @JoinTable(name = "tr_project_group", joinColumns = @JoinColumn(name = "project_id"),
            inverseJoinColumns = @JoinColumn(name = "group_id"))
    private List<Group> groups = Lists.newArrayList();

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Integer getYieldCycleValue() {
        return yieldCycleValue;
    }

    public void setYieldCycleValue(Integer yieldCycleValue) {
        this.yieldCycleValue = yieldCycleValue;
    }

    public Boolean getYieldCycleUnit() {
        return yieldCycleUnit;
    }

    public void setYieldCycleUnit(Boolean yieldCycleUnit) {
        this.yieldCycleUnit = yieldCycleUnit;
    }

    public Date getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Date updateTime) {
        this.updateTime = updateTime;
    }

    public List<Group> getGroups() {
        return groups;
    }

    public void setGroups(List<Group> groups) {
        this.groups = groups;
    }

}
